/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * RealizarPagoFrame.java
 *
 * Created on 11/07/2011, 05:17:09 PM
 */
package jacidco;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.StringTokenizer;
import java.util.Vector;

/**
 *
 * @author Sefer Sephirott
 */
public class RealizarPagoFrame extends javax.swing.JFrame implements BotonesNuevoCrearCancelar
{

    private int id;
    private int codPago;
    private int codAfiliado;
    private String estado;
    private String periodo;
    private String ano;
    private String semestre;
        
    /** Creates new form RealizarPagoFrame */
    public RealizarPagoFrame() 
    {
        initComponents();
        
        fillComboBox();
        
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        lblTitulo = new javax.swing.JLabel();
        jPanel1 = new javax.swing.JPanel();
        lblCodigoAfiliado = new javax.swing.JLabel();
        txtCodigoAfiliad = new javax.swing.JTextField();
        lblNombreAfiliado = new javax.swing.JLabel();
        txtNombreAfiliado = new javax.swing.JTextField();
        lblApellidoAfiliado = new javax.swing.JLabel();
        txtApellidoAfiliado = new javax.swing.JTextField();
        cmbPago = new javax.swing.JComboBox();
        lblPago = new javax.swing.JLabel();
        lblValor = new javax.swing.JLabel();
        txtValor = new javax.swing.JTextField();
        lblSemestre = new javax.swing.JLabel();
        lblEstado = new javax.swing.JLabel();
        cmbEstado = new javax.swing.JComboBox();
        cmbSemestre = new javax.swing.JComboBox();
        cmbAno = new javax.swing.JComboBox();
        btnActualizarPagos = new javax.swing.JButton();
        jLabel1 = new javax.swing.JLabel();
        lblTitulo4 = new javax.swing.JLabel();
        lblMarcareg = new javax.swing.JLabel();
        btmPagar = new javax.swing.JButton();
        btnNuevo = new javax.swing.JButton();
        btnCancelar = new javax.swing.JButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

        lblTitulo.setFont(new java.awt.Font("Times New Roman", 3, 18));
        lblTitulo.setText("Comunidad Dinamica en Java");
        lblTitulo.setName("lblTitulo"); // NOI18N

        jPanel1.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED));
        jPanel1.setName("jPanel1"); // NOI18N

        lblCodigoAfiliado.setFont(new java.awt.Font("Tahoma", 2, 11));
        lblCodigoAfiliado.setText("Cod. Afiliado :");
        lblCodigoAfiliado.setName("lblCodigoAfiliado"); // NOI18N

        txtCodigoAfiliad.setName("txtCodigoAfiliad"); // NOI18N
        txtCodigoAfiliad.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusLost(java.awt.event.FocusEvent evt) {
                txtCodigoAfiliadFocusLost(evt);
            }
        });

        lblNombreAfiliado.setFont(new java.awt.Font("Tahoma", 2, 11));
        lblNombreAfiliado.setText("Nombre :");
        lblNombreAfiliado.setName("lblNombreAfiliado"); // NOI18N

        txtNombreAfiliado.setEditable(false);
        txtNombreAfiliado.setName("txtNombreAfiliado"); // NOI18N

        lblApellidoAfiliado.setFont(new java.awt.Font("Tahoma", 2, 11));
        lblApellidoAfiliado.setText("Apellido :");
        lblApellidoAfiliado.setName("lblApellidoAfiliado"); // NOI18N

        txtApellidoAfiliado.setEditable(false);
        txtApellidoAfiliado.setName("txtApellidoAfiliado"); // NOI18N

        cmbPago.setName("cmbPago"); // NOI18N
        cmbPago.addItemListener(new java.awt.event.ItemListener() {
            public void itemStateChanged(java.awt.event.ItemEvent evt) {
                cmbPagoItemStateChanged(evt);
            }
        });

        lblPago.setFont(new java.awt.Font("Tahoma", 2, 11));
        lblPago.setText("Pago :");
        lblPago.setName("lblPago"); // NOI18N

        lblValor.setFont(new java.awt.Font("Tahoma", 2, 11));
        lblValor.setText("Valor : ");
        lblValor.setName("lblValor"); // NOI18N

        txtValor.setEditable(false);
        txtValor.setName("txtValor"); // NOI18N

        lblSemestre.setFont(new java.awt.Font("Tahoma", 2, 11));
        lblSemestre.setText("Semestre : ");
        lblSemestre.setName("lblSemestre"); // NOI18N

        lblEstado.setFont(new java.awt.Font("Tahoma", 2, 11)); // NOI18N
        lblEstado.setText("Estado :");
        lblEstado.setName("lblEstado"); // NOI18N

        cmbEstado.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Pendiente", "Cancelado" }));
        cmbEstado.setName("cmbEstado"); // NOI18N
        cmbEstado.addItemListener(new java.awt.event.ItemListener() {
            public void itemStateChanged(java.awt.event.ItemEvent evt) {
                cmbEstadoItemStateChanged(evt);
            }
        });

        cmbSemestre.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "1", "2" }));
        cmbSemestre.setName("cmbSemestre"); // NOI18N

        cmbAno.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "2011", "2012", "2013", "2014", "2015", "2016", "2017", "2018", "2019", "2020" }));
        cmbAno.setName("cmbAno"); // NOI18N

        btnActualizarPagos.setText("Actualizar");
        btnActualizarPagos.setName("btnActualizarPagos"); // NOI18N
        btnActualizarPagos.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnActualizarPagosActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(lblEstado)
                    .addComponent(lblPago)
                    .addComponent(lblCodigoAfiliado)
                    .addComponent(lblNombreAfiliado)
                    .addComponent(lblSemestre))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addComponent(cmbEstado, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addContainerGap())
                    .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                        .addGroup(jPanel1Layout.createSequentialGroup()
                            .addComponent(cmbSemestre, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                            .addComponent(cmbAno, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                            .addComponent(btnActualizarPagos)
                            .addGap(174, 174, 174))
                        .addGroup(jPanel1Layout.createSequentialGroup()
                            .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                                .addComponent(cmbPago, 0, 134, Short.MAX_VALUE)
                                .addComponent(txtNombreAfiliado, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.PREFERRED_SIZE, 128, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addComponent(txtCodigoAfiliad, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.PREFERRED_SIZE, 66, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addGap(26, 26, 26)
                            .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                                .addComponent(lblApellidoAfiliado)
                                .addComponent(lblValor))
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                            .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                .addComponent(txtValor)
                                .addComponent(txtApellidoAfiliado, javax.swing.GroupLayout.PREFERRED_SIZE, 112, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addGap(29, 29, 29)))))
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGap(26, 26, 26)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(txtCodigoAfiliad, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(lblCodigoAfiliado))
                .addGap(18, 18, 18)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(txtApellidoAfiliado, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(lblApellidoAfiliado))
                        .addGap(18, 18, 18)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(txtValor, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(lblValor)))
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(txtNombreAfiliado, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(lblNombreAfiliado))
                        .addGap(18, 18, 18)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(lblPago)
                            .addComponent(cmbPago, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(18, 18, 18)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(lblSemestre)
                            .addComponent(cmbSemestre, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(cmbAno, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(btnActualizarPagos))))
                .addGap(18, 18, 18)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(lblEstado)
                    .addComponent(cmbEstado, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(48, 48, 48))
        );

        jLabel1.setBackground(new java.awt.Color(255, 51, 51));
        jLabel1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/jacidco/resources/Logo_Jacidco_mini.png"))); // NOI18N
        jLabel1.setName("jLabel1"); // NOI18N

        lblTitulo4.setFont(new java.awt.Font("Times New Roman", 3, 36));
        lblTitulo4.setText("Pagos Afiliado");
        lblTitulo4.setName("lblTitulo4"); // NOI18N

        lblMarcareg.setFont(new java.awt.Font("Times New Roman", 0, 11));
        lblMarcareg.setText("Copyright 2011. DCM. All Rights Reserved");
        lblMarcareg.setName("lblMarcareg"); // NOI18N

        btmPagar.setFont(new java.awt.Font("Tahoma", 3, 11));
        btmPagar.setText("Pagar");
        btmPagar.setName("btmPagar"); // NOI18N
        btmPagar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btmPagarActionPerformed(evt);
            }
        });

        btnNuevo.setFont(new java.awt.Font("Tahoma", 3, 11));
        btnNuevo.setText("Nuevo");
        btnNuevo.setName("btnNuevo"); // NOI18N
        btnNuevo.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnNuevoActionPerformed(evt);
            }
        });

        btnCancelar.setFont(new java.awt.Font("Tahoma", 3, 11));
        btnCancelar.setText("Cancelar");
        btnCancelar.setName("btnCancelar"); // NOI18N
        btnCancelar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnCancelarActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(jLabel1)
                        .addGap(18, 18, 18)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(lblTitulo, javax.swing.GroupLayout.PREFERRED_SIZE, 285, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(lblTitulo4)))
                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                        .addGroup(layout.createSequentialGroup()
                            .addComponent(btnNuevo)
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                            .addComponent(btmPagar, javax.swing.GroupLayout.PREFERRED_SIZE, 69, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                            .addComponent(btnCancelar))
                        .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addComponent(lblMarcareg))
                .addContainerGap(14, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel1)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(lblTitulo)
                        .addGap(67, 67, 67)
                        .addComponent(lblTitulo4)))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, 244, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(btnCancelar)
                    .addComponent(btmPagar)
                    .addComponent(btnNuevo))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(lblMarcareg)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void btmPagarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btmPagarActionPerformed
        
        try
        {
            if(capturaDatos())
            {
                actualizaPagoACancelado();
            }
            
        }
        catch(Exception ex)
        {
            
        }
        
    }//GEN-LAST:event_btmPagarActionPerformed

    private void btnNuevoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnNuevoActionPerformed
        
        limpiarCampos();
        
    }//GEN-LAST:event_btnNuevoActionPerformed

    private void btnCancelarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnCancelarActionPerformed
        
        Main.goToMenuPrincipal();
        dispose();
        
    }//GEN-LAST:event_btnCancelarActionPerformed

    private void txtCodigoAfiliadFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_txtCodigoAfiliadFocusLost
        
        muestraNombreApellidoEmpleado();   
        
    }//GEN-LAST:event_txtCodigoAfiliadFocusLost

    private void cmbPagoItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_cmbPagoItemStateChanged
        
        
        muestraValorPago();
        
    }//GEN-LAST:event_cmbPagoItemStateChanged

    private void cmbEstadoItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_cmbEstadoItemStateChanged
        
    }//GEN-LAST:event_cmbEstadoItemStateChanged

    private void btnActualizarPagosActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnActualizarPagosActionPerformed

         periodo = cmbSemestre.getItemAt(cmbSemestre.getSelectedIndex()).toString();
         ano = cmbAno.getItemAt(cmbAno.getSelectedIndex()).toString();
         estado = cmbEstado.getItemAt(cmbEstado.getSelectedIndex()).toString();
         actualizaDatos();
         

    }//GEN-LAST:event_btnActualizarPagosActionPerformed

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton btmPagar;
    private javax.swing.JButton btnActualizarPagos;
    private javax.swing.JButton btnCancelar;
    private javax.swing.JButton btnNuevo;
    private javax.swing.JComboBox cmbAno;
    private javax.swing.JComboBox cmbEstado;
    private javax.swing.JComboBox cmbPago;
    private javax.swing.JComboBox cmbSemestre;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JLabel lblApellidoAfiliado;
    private javax.swing.JLabel lblCodigoAfiliado;
    private javax.swing.JLabel lblEstado;
    private javax.swing.JLabel lblMarcareg;
    private javax.swing.JLabel lblNombreAfiliado;
    private javax.swing.JLabel lblPago;
    private javax.swing.JLabel lblSemestre;
    private javax.swing.JLabel lblTitulo;
    private javax.swing.JLabel lblTitulo4;
    private javax.swing.JLabel lblValor;
    private javax.swing.JTextField txtApellidoAfiliado;
    private javax.swing.JTextField txtCodigoAfiliad;
    private javax.swing.JTextField txtNombreAfiliado;
    private javax.swing.JTextField txtValor;
    // End of variables declaration//GEN-END:variables

    /**
     * Captura los datos en los JTextField del formulario
     */
    public boolean capturaDatos() 
    {

        codPago = (cmbPago.getSelectedIndex()+1);
        codAfiliado = Integer.parseInt(txtCodigoAfiliad.getText());
        estado = cmbEstado.getItemAt(cmbEstado.getSelectedIndex()).toString();
        periodo = cmbSemestre.getItemAt(cmbSemestre.getSelectedIndex()).toString();
        ano = cmbAno.getItemAt(cmbAno.getSelectedIndex()).toString();
        return true;
    }

    /**
     * Realiza la insersion de datos en la Base de Datos, sobre el pago realizado por un afiliado 
     * 
     * @param Id            el id del pago realizado
     * @param CodPago       el codigo del pago a realizar
     * @param CodAfiliado   el codigo del afiliado que realiza el pago
     * @param Estado        el estado que se adquiere el pago reaslizado por el afiliado
     * @param Semestre      el semestre al cual pertenece el pago realizado
     */
    public boolean actualizaDatos() 
    {
        
        try
        {
            semestre = periodo+"-"+ano; 

            Main.bd.conectar();

            Main.bd.inicializaDatosPagoRealizado(semestre);

            Main.mensaje.datosGuardaosOK("Pago Realizado Exitosamente");

            txtCodigoAfiliad.setEnabled(false);
            cmbEstado.setEnabled(false);
            cmbPago.setEnabled(false);  
            
            Main.bd.cerrarConexion();
        }
        catch(Exception e)
        {
            
        }

        
        return true;
    }

    /**
     * 
     */
    public void actualizaPagoACancelado()
    {
        semestre = periodo+"-"+ano;
        Main.bd.conectar();
        if(Main.bd.actualizaPagosACancelado(codAfiliado, semestre, codPago, estado))
        {
            Main.mensaje.datosGuardaosOK("Pago Cancelado");
        }
        Main.bd.cerrarConexion();
    }
    
    
    /**
     * limpia  y habilita los campos para realizar un nuevo pago
     */
    public boolean limpiarCampos() 
    {
        txtCodigoAfiliad.setText("");
        txtNombreAfiliado.setText("");
        txtApellidoAfiliado.setText("");

        
        txtCodigoAfiliad.setEnabled(true);
        cmbEstado.setEnabled(true);
        cmbPago.setEnabled(true);
        return true;
    }
    
    /**
     * Llena el combo box del pago, con el nombre de los pagos disponibles
     */
    public void fillComboBox()
    {
        Main.bd.conectar();
        
        int cap = Main.bd.nextCode("cod_pago","pagos")+1;
        
        Vector nombre = new Vector(cap);
        Vector nombre2 = new Vector(cap);
        
        nombre2 = Main.bd.muestraDatosComboBoxes(nombre,"pagos");
        
        for(int i=1;i<cap;i++)
        {
            cmbPago.addItem(nombre2.get(i));
        }
        
        Main.bd.cerrarConexion();
    }
    
    /**
     * Muestra el Nombre y Apellido del Afiliado que va a realizar el pago
     */
    public void muestraNombreApellidoEmpleado()
    {
        int cod = Integer.parseInt(txtCodigoAfiliad.getText());
        
        Main.bd.conectar();
        ResultSet rs = Main.bd.buscaAfiliado(cod);
        
         try
        {
            if(rs.next())
            {
                txtNombreAfiliado.setText(rs.getString("primer_nombre"));
                txtApellidoAfiliado.setText(rs.getString("primer_apellido"));
            }
            else
            {
                Main.mensaje.advertencia("Afiliado no Existe");
            }
        }
        catch (SQLException ex)
        {
            
        }
        Main.bd.cerrarConexion();
    }
    
    /**
     * Muestra el valor del capo seleccionado
     */
    public void muestraValorPago()
    {
        int item = cmbPago.getSelectedIndex();
        
        Main.bd.conectar();
        txtValor.setText(Main.bd.consulatValorPago(item+1));
        Main.bd.cerrarConexion();
    }

    public boolean guardaDatos() {
        throw new UnsupportedOperationException("Not supported yet.");
    }


}
